const db = require('../models')
const Tutorials = db.tutorials

exports.create = (req, res) => {
    if (!req.body.title) {
        res.status(400).send({
            message: '课程名称不能为空',
        })
        return
    }
    
    const turtorial = {
        title: req.body.title,
        description: req.body.description,
        published: req.body.published
    }
    Tutorials.create(turtorial).then(data => {
        console.log(req.body)
        res.send(data)
    }).catch(err => {
        console.log(err.message || '接口报错')
        res.status(500).send({
            message: err.message || '接口报错'
        })
    })
}
